{layout name="../common/master"/}
<div id="right">
       <h4 style="border-bottom: 1px solid #ccc;padding-bottom: 3px">所有优惠券列表   <a type="button" href="{:URL('home/Coupon/couponAdd')}" class="btn btn-success">添加</a></h4>
    <!--<form action="" method="post" role="form">-->
        <!--<div class="form-group">-->
            <!--<input type="text" style="width: 200px;float: left;margin-right: 20px" class="form-control" value="{if condition='isset($uname)'}{$uname}{/if}" name="uname" id="" placeholder="上传名">-->
        <!--</div>-->
        <!--<button type="submit" class="btn btn-primary">查询</button>-->
        <!--<a href="{:URL('home/Docmanager/docupload')}" class="btn btn-success">上传文件</a>-->
    <!--</form>-->
    <table class="table-bordered table  table-hover" style="margin-top: 20px;">
        <thead>
        <tr>
            <th>序号</th>
            <th>名称</th>
            <th>类型</th>
            <th>金额</th>
            <th>适用产品类型</th>
            <th>有效开始时间</th>
            <th>有效结束时间</th>
            <th>金额上限</th>
            <th>金额下限</th>
            <th>状态</th>
            <th>适用平台</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach name="data" item="vo" key="k"}
            <tr>
                <th>{$vo['id']}</th>
                <th>{$vo['name']}</th>
                {if condition="$vo['type'] eq 1"}
                <th>折价券</th>
                {elseif condition="$vo['type'] eq 2"}
                <th>免息券</th>
                {/if}
                <th>{$vo['bonus']}</th>
                <th>
                    {if condition="$vo['attachedProductType'] eq 1"}
                    0307
                {elseif condition="$vo['attachedProductType'] eq 2"/}
                     0314
                {elseif condition="$vo['attachedProductType'] eq 3"/}
                     0607
                {elseif condition="$vo['attachedProductType'] eq 4"/}
                    0614
                    {elseif condition="$vo['attachedProductType'] eq 5"/}
                    1007
                    {elseif condition="$vo['attachedProductType'] eq 6"/}
                    1015
                    {elseif condition="$vo['attachedProductType'] eq 100"/}
                    EWI
                    {/if}
                   </th>
                <th>{$vo['use_start_time']}</th>
                <th>{$vo['use_end_time']}</th>
                <th>{$vo['upperAmount']}</th>
                <th>{$vo['downAmount']}</th>
                {if condition="$vo['status'] eq 0" }
                <th>未激活</th>
                {elseif condition="$vo['status'] eq 1"/}
                <th>已激活</th>
                {/if}
                <th>{$vo['platFormID']}</th>
                <th>{:gmtToIndiaTime($vo['create_time'])}</th>
                <th>
                    <div class="btn-group">
                        {if condition="$vo['status'] eq 0" }
                        <button uid="{$vo['id']}" class="toStore btn btn-success btn-sm">激活</button>
                        {elseif condition="$vo['status'] eq 1"/}
                        <button uid="{$vo['id']}" class="downStore btn btn-danger btn-sm">下线</button>
                        {/if}
                        <a style="margin-left: 5px" href="{:URL('home/Coupon/editCoupon',['uid'=>$vo['id']])}" class="btn btn-primary btn-sm">修改</a>
                    </div>
                </th>
            </tr>
        {/foreach}
        </tbody>
    </table>
    {$page} 总产品数：{$totalCount}

</div>
<script>
    $(".toStore").click(function(){
        var data={
            status:1
        }
        var id=$(this).attr('uid');
        var url="{:URL('home/Coupon/upStore')}"+"?id="+id;
        $.post(url,data,function(res){
            if(res.code == 0){
                location.reload();
            }else{
                layer.msg(res.data,function(){});
            }
        })
    })
    $(".downStore").click(function(){
        var data={
            status:0
        }
        var id=$(this).attr('uid');
        var url="{:URL('home/Coupon/upStore')}"+"?id="+id;
        $.post(url,data,function(res){
            if(res.code == 0){
                location.reload();
            }else{
                layer.msg(res.data,function(){});
            }
        })
    })
</script>
